<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Released under the MIT License.
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------

namespace app\home\controller;

use think\request;
use cmf\controller\HomeBaseController;

class BaseController extends HomeBaseController
{ 

	protected $member_id;

        public function initialize()
        {
                parent::initialize();

                 //判断是否登录
                $userId = cmf_get_current_user_id();
                //是否存在session
                //记录登录url
                $login_url = request()->url();

                //如果不是登录页，就session存起来
                if(strpos($login_url, 'wx_login') === false)
                {
                    session('login_url', $login_url);
                }
                
                
                if (empty($userId)) {
                	$this->redirect('/wx_login');
                }else{
                	$this->member_id = $userId;
                }

        }

}